package org.lw.springbootlw.common.mapper.auth;


import org.apache.ibatis.annotations.*;
import org.lw.springbootlw.common.model.Permission;

import java.util.List;

@Mapper
public interface PermissionMapper {

    // 查询所有权限
    @Select("SELECT id, permission_name, description FROM Permissions")
    List<Permission> findAllPermissions();

    // 根据权限ID查询单个权限
    @Select("SELECT id, permission_name, description FROM Permissions WHERE id = #{id}")
    Permission findPermissionById(@Param("id") Long id);

    // 查询特定角色的所有权限
    @Select("SELECT p.id, p.permission_name FROM Permissions p " +
            "JOIN RolePermissions rp ON p.id = rp.permission_id " +
            "WHERE rp.role_id = #{roleId}")
    List<Permission> findPermissionsByRoleId(@Param("roleId") Long roleId);
}
